package 二分查找;

/**
 * @author tmh
 * @date 2024/12/5 21:50
 * @description
 */
public class T153寻找旋转排序数组中的最小值 {
    public int findMin(int[] nums) {
        int left = 0;
        int n = nums.length - 1;
        int right = nums.length - 1;
        while (left < right) {
            int mid = left + ((right - left) >> 1);
            if (nums[mid] > nums[n]) {
                //说明最小值在右侧
                left = mid + 1;
            } else {
                //说明最小值在mid或者左侧
                right = mid;
            }
        }
        return nums[right];
    }
}
